/**
 * Created by xujz on 15/12/01.
 */
lenovo_like_tag=0;
var _trackData = window._trackData || [];
$(function(){
	//猜你喜欢
	getNextGroupLike();

	//划过
	$('#like_cont li').hover(function(){
		$(this).addClass("like_red");
	},function(){
		$(this).removeClass("like_red");
	});
});
//换一批
function getNextGroupLike (){
	$.ajax({
		url :"http://www.lenovo.com.cn/api/products/getinstantpersonalization",
		data: {
			nums:6,
			salesPlat:1,
			goodsCode:'00000',
			position:1,
			pageIndex:lenovo_like_tag%3
		},
		type : "get",
		dataType : 'json',
		timeout : 1000,
		//jsonp:'callback',
		success : function(data) {
			var htmls = '<input type="hidden" value="" id="LA_TAG_ELEMENID" />';
			var yifenxi='';
			if(data.length>0){
				var tmparr = ['show','goodsid','A0000'];
				for(var o=0;o<data.length;o++){
					
					if(o!=5){
						yifenxi+='latag_pc_home_like_rec_'+(o+1)+'_A0000_'+data[o].code+'_'+data[o].flag+',';
					}else{
						yifenxi+='latag_pc_home_like_rec_'+(o+1)+'_A0000_'+data[o].code+'_'+data[o].flag+',';
					}
					if(o>5){
						break;
					}
					htmls+= '<li latag="latag_pc_home_like_rec_'+(o+1)+'_A0000_'+data[o].code+'_'+data[o].flag+'">'
						+'<a href="/product/'+data[o].code+'.html"><img src="'+data[o].path+'"></a>'
						+'<p class="like_name"><a href="/product/'+data[o].code+'.html">'+data[o].name+'</a></p>'
						+'<p class="like_price"><a href="/product/'+data[o].code+'.html">'+data[o].price+'元</a></p>'
						+'</li>';
				}
				tmparr.push(yifenxi);
				_trackData.push(tmparr);

				$(".like_cont").html(htmls);
				$("#LA_TAG_ELEMENID").val(yifenxi);
				$("#like_cont").addClass("hasdata");
				lenovo_like_tag++;
			}else{
				$("#J-like-box").hide();
				$(".hunter").hide();
				$(".ns_line hunter").hide();
				$("#like_cont").removeClass("hasdata");
				return;
			}
		},
		error:function(){
			$("#J-like-box").hide();
			$(".hunter").hide();
			$(".ns_line hunter").hide();
		}
	});
}
